#include <iostream>
#include <vector>
using namespace std;

class segment_tree {
	vector<int> color;
	vector<int> lazyinfo;

	void lazy(int i, int v)
	{
		color[i] = (1 << v);
		lazyinfo[i] = v;
	}

	void up(int i)
	{
		color[i] = color[i << 1] | color[i << 1 | 1];
	}

	void down(int i)
	{
		if (lazyinfo[i]) {
			lazy(i << 1, lazyinfo[i]);
			lazy(i << 1 | 1, lazyinfo[i]);
			lazyinfo[i] = 0;
		}
	}

	void build(int l, int r, int i)
	{
		if (l == r) {
			color[i] = 2;
		} else {
			int mid = (l + r) >> 1;
			build(l, mid, i << 1);
			build(mid + 1, r, i << 1 | 1);
			up(i);
		}
	}

    public:
	segment_tree(int n) : color(n << 2, 0), lazyinfo(n << 2, 0)
	{
                build(1, n, 1);
	}

	void update(int jobl, int jobr, int v, int l, int r, int i)
	{
		if (jobl <= l && r <= jobr) {
			lazy(i, v);
		} else {
			int mid = (l + r) >> 1;
			down(i);
			if (jobl <= mid) {
				update(jobl, jobr, v, l, mid, i << 1);
			}
			if (mid < jobr) {
				update(jobl, jobr, v, mid + 1, r, i << 1 | 1);
			}
			up(i);
		}
	}

	int query(int jobl, int jobr, int l, int r, int i)
	{
		if (jobl <= l && r <= jobr) {
			return color[i];
		}
		int mid = (l + r) >> 1;
                down(i);
		int ans = 0;
		if (jobl <= mid) {
			ans |= query(jobl, jobr, l, mid, i << 1);
		}
		if (mid < jobr) {
			ans |= query(jobl, jobr, mid + 1, r, i << 1 | 1);
		}
		return ans;
	}
};

int cntbit(int x)
{
        int ans = 0;
        while(x){
                if(x & 1){
                        ans++;
                }
                x >>= 1;
        }
        return ans;
}

int main()
{
        int n, t, m, ans = 0;
        cin >> n >> t >> m;
        segment_tree sgt(n);
        char op;
        for(int i = 0, l, r, v; i < m; i++){
                cin >> op >> l >> r;
                if( l > r){
                        swap(l, r);
                }
                if(op == 'C'){
                        cin >> v;
                        sgt.update(l, r, v, 1, n, 1);
                }else{
                        ans = sgt.query(l, r, 1, n, 1);
                        cout << cntbit(ans) << '\n';
                }
        }
	return 0;
}